class Image < Asset
	belongs_to :article, :foreign_key => :assetable_id
	
	has_attachment :content_type => :image, 
	         :storage => :file_system, :path_prefix => 'public/attachments/images',
	         :max_size => 4.megabytes,
	         :size => 0.kilobytes..4000.kilobytes,
	         :resize_to => '1280x800>',
           :processor => 'Rmagick',
           :thumbnails => { :content => '540x300!', :middle => '120x90!' ,:thumb => '154x116!'}
	         
	validates_as_attachment
	
	def before_create
		extension = self.filename.scan(/\.\w+$/)
		self.filename = self.filename.parameterize.gsub(/\-\w+$/,'').to_s+"#{extension}"
	end
end
